
param([system.IO.FileInfo]$fullpath = $(Throw "Enter a full path for destination text file - ex. c:\temp\password.txt"))

$cred = Get-Credential "UserNameNotRequired"
$cred.Password | ConvertFrom-SecureString | Set-Content $fullpath -Force
if (Test-Path $fullpath)
{
	Write-Host "The secure password file  has been created at $fullpath" 
	Write-Host 'Use the following code in your target script to make use of the secured text file.'
	Write-Host '$password = Get-Content $fullpath | ConvertTo-SecureString' -backgroundcolor white -foregroundcolor black
	Write-Host '$cred = New-Object system.Management.Automation.PSCredential "someuser",$password' -backgroundcolor white -foregroundcolor black
	Write-Warning "The use of the secured password file will only work with the computer it was created on."
}
else 
{
	Throw "File was not created - verify path is valid"
}
